﻿using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NetCoreClass
{
    public class Logs
    {
        private static readonly string _logPath= "log/log.txt";

        public Logs()
        {
        }

        public static void Debug(Object message)
        {
            //var logMessage = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}  {message}";

            //// 输出到控制台
            //Console.WriteLine(logMessage);

            //// 输出到文本文件
            //using (var writer = new StreamWriter(_logPath, true))
            //{
            //    writer.WriteLine(logMessage);
            //}
        }
        public static void Debug(string key, Object message)
        {
            var logMessage = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}{key} : {message}";

            // 输出到控制台
            Console.WriteLine(logMessage);

            // 输出到文本文件
            using (var writer = new StreamWriter(_logPath, true))
            {
                writer.WriteLine(logMessage);
            }
        }
    }
}
